package org.meeting.radish.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.meeting.radish.entity.User;
import org.meeting.radish.mapper.UserMapper;
import org.meeting.radish.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.List;

@Slf4j
@Service
public class UserServiceImpl implements UserService {

    @Resource
    UserMapper userMapper;

    @Override
    public Integer addUser(User user) {
        Integer integer = userMapper.addUser(user);
        log.info("用户插入完成");
        return integer;
    }

    @Override
    public Integer updateUser(User user) {
        Integer integer = userMapper.updateUser(user);
        log.info("用户修改完成");
        return integer;
    }

    @Override
    public User queryUser(User user) {
        user = userMapper.queryUser(user);
        return user;
    }

    @Override
    public User queryUser(Integer uid) {
        return userMapper.queryUserById(uid);
    }

    @Override
    public List<User> queryAllUser() {
        List<User> users = userMapper.queryAllUser();
        log.info("全部用户查询完毕");
        return users;
    }

    @Override
    public List<User> queryUserRequest() {
        return userMapper.queryUserRequest();
    }
}
